package com.example.obs.utils;

import com.example.obs.model.domin.CurrentPage;

import java.util.List;

public class PageUtils {

    public static List<?> pagehelper(List<?> list, CurrentPage currentPage){
        int total=list.size();
        int pageCount=(total/currentPage.getSize())+((total%(currentPage.getSize())>0)?1:0);
        int start=currentPage.getCurrt()*currentPage.getSize();
        int end=(currentPage.getCurrt()+1)<pageCount?(currentPage.getCurrt())*currentPage.getSize()+currentPage.getSize():total;
        list=list.subList(start,end);
        return list;
    }

}
